package com.xingfu.mybatisdemo.rest;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.xingfu.mybatisdemo.dto.UserDTO;
import com.xingfu.mybatisdemo.persistence.po.SysUsers;
import com.xingfu.mybatisdemo.service.IMerchantService;
import com.xingfu.mybatisdemo.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nzx
 * @version 1.0
 * @date 2019/10/29
 * @description:
 **/
@RestController
public class MerchantController {

    @Autowired
    private IMerchantService merchantService;

    @RequestMapping(value = "/getUser",method = RequestMethod.GET)
    private UserVO getUser(){
        return merchantService.getUserAndRole(7L);
    }

    @RequestMapping(value = "/addUser",method = RequestMethod.GET)
    private Long addUser(){
        UserDTO userDTO = new UserDTO();
        userDTO.setDescription("描述");
        userDTO.setPassword("123");
        userDTO.setRealName("san");
        userDTO.setUserName("san");
        return merchantService.insertUser(userDTO);
    }

    @RequestMapping(value = "/getUserList",method = RequestMethod.GET)
    private PageInfo<SysUsers> getUserList(){
        PageInfo<SysUsers> pageInfo = null;
        pageInfo = merchantService.getUserByPage(0,4);
        return pageInfo;
    }

    @RequestMapping(value = "/getUserByTime",method = RequestMethod.GET)
    private List<SysUsers> getUserByTime(){
        return merchantService.getUserByDate("2019-10-31");
    }


}
